<template>
    <div class="ContractInfo" style="width: 100%;">
        <rui-form :form-options="formOptions" :label-width="120" :read-only="true" ref="formData"></rui-form>
    </div>
</template>

<script>
    import {add} from "_p/basic/assets/contract/js/utils";

    export default {
        props: {
            contractNo: {
                type: String,
                required: true
            }
        },
        data() {
            return {
                defines: [],
                formOptions: [
                    {
                        isGroup: false,
                        grids: [
                            {
                                defineId: "defineData",
                                span: 8,
                                fields: ["countTerm", "monthPayAmt", "totalDiscountAmt", "succeedTime"]
                            },
                            {
                                defineId: "defineData",
                                span: 8,
                                fields: ["paidTerm", "overdueTerm", "receivableTotal", "arriveAmt"]
                            },
                            {
                                defineId: "defineData",
                                span: 8,
                                fields: ["unpaidTerm", "nextRepaymentTerm", "interestTotal"]
                            }
                        ]
                    },
                ]
            };
        },

        mounted() {
        },
        methods: {
            updateData(data) {
                if (!data) return;

                this.$refs.formData.updateFormData(data);
                if (data.paidTerm === 0) {
                    this.$refs.formData.setFiledValue('paidTerm', '0')
                }
                if (data.overdueTerm === 0) {
                    this.$refs.formData.setFiledValue('overdueTerm', '0')
                }
                if (data.totalDiscountAmt === undefined) {
                    this.$refs.formData.setFiledValue('totalDiscountAmt', '0')
                }
                if (data.succeedTime === undefined) {
                    this.$refs.formData.setFiledValue('succeedTime', '')
                }
                if (data.arriveAmt === undefined) {
                    this.$refs.formData.setFiledValue('arriveAmt', '0')
                }
                this.$refs.formData.setFiledValue('unpaidTerm', add(data.unpaidTerm, data.overdueTerm));
            }
        }
    };
</script>

<style>
</style>
